﻿namespace Acme.Marketing.Test.Integration
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using Data;
    using Marketing.DataAccess;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    ///     HACK: This is an integration test used in this sample application.
    ///     TODO: Implement dependency injection and mocking for separation of concerns.
    /// </summary>
    [TestClass]
    public class DataAccess
    {
        // TODO: Finish this.
        [TestMethod]
        public void TestCreateNewspaper()
        {
            Database.SetInitializer<MarketingContext>(null);

            var paper = new Newspaper
            {
                NewspaperId = 1,
                Headline = "Why hello there!",
                ExternalGuid = Guid.NewGuid(),
                PublishDate = DateTime.Now.AddDays(2),
                NumberOfSubscribers = 1200
            };

            paper.Advertisements = new List<Advertisement>();
            paper.Advertisements.Add(new Advertisement
            {
                AdvertisementId = 1,
                Cost = 450.54M,
                PixelHeight = 1000,
                PixelWidth = 400
            });

            // TODO: Save to teh database 
            using (var db = new MarketingContext())
            {
                db.Newspapers.Add(paper);
                db.SaveChanges();
            }
        }
    }
}